﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace BiessesXmlReader
{
    public class Board
    {
        public string id { get; private set; }
        public double L { get; private set; }
        public double W { get; private set; }
        public string Type { get; private set; }
        public string BrdNo { get; private set; }
        public string MatNo { get; private set; }
        public double Thickness { get; private set; }
        public double BTrim { get; private set; }
        public double LTrim { get; private set; }
        public double RTrim { get; private set; }
        public double TTrim { get; private set; }
        public static Board GetBoard(XElement x)
        {
            Board B = new Board();
            XElement xb = x.Element("Board");
            B.L = (xb.Attribute("L") == null) ? 0 : double.Parse(xb.Attribute("L").Value);
            B.W = (xb.Attribute("W") == null) ? 0 : double.Parse(xb.Attribute("W").Value);
            B.Type = (xb.Attribute("Type") == null) ? string.Empty : xb.Attribute("Type").Value;
            B.BrdNo = (xb.Attribute("BrdNo") == null) ? string.Empty : xb.Attribute("BrdNo").Value;
            B.MatNo = (xb.Attribute("MatNo") == null) ? string.Empty : xb.Attribute("MatNo").Value;
            B.Thickness = (xb.Attribute("Thickness") == null) ? 0 : double.Parse(xb.Attribute("Thickness").Value);
            B.LTrim = (xb.Attribute("LTrim") == null) ? 0 : double.Parse(xb.Attribute("LTrim").Value);
            B.RTrim = (xb.Attribute("RTrim") == null) ? 0 : double.Parse(xb.Attribute("RTrim").Value);
            B.TTrim = (xb.Attribute("TTrim") == null) ? 0 : double.Parse(xb.Attribute("TTrim").Value);
            B.BTrim = (xb.Attribute("BTrim") == null) ? 0 : double.Parse(xb.Attribute("BTrim").Value);
            B.id = (xb.Attribute("id") == null) ? string.Empty : xb.Attribute("id").Value;
            B.id = (xb.Attribute("id") == null) ? string.Empty : xb.Attribute("id").Value;
            B.id = (xb.Attribute("id") == null) ? string.Empty : xb.Attribute("id").Value;
            B.id = (xb.Attribute("id") == null) ? string.Empty : xb.Attribute("id").Value;
            B.id = (xb.Attribute("id") == null) ? string.Empty : xb.Attribute("id").Value;
            B.id = (xb.Attribute("id") == null) ? string.Empty : xb.Attribute("id").Value;
            B.id = (xb.Attribute("id") == null) ? string.Empty : xb.Attribute("id").Value;
            return B;
        }
    }
}
